﻿@using Smartstore.Web.Models.Customers

@model UserAgreementModel

@{
    var pageTitle = T("DownloadableProducts.UserAgreement");
    Assets.AppendTitleParts(pageTitle);

    ViewBag.PageTitle = pageTitle.Value;
}

<div class="page user-agreement-page">
    <div class="page-title">
        <h1>@pageTitle</h1>
    </div>
    <div class="page-body">
        <fieldset>
            <legend id="agreement-legend" class="sr-only">@T("Common.Consent")</legend>
            <div dir="auto">
                @Html.Raw(Model.UserAgreementText)
            </div>
            <div>
                <div class="download-agreement alert alert-info">
                    <label for="download-agreement" class="checkbox mb-0">
                        <input id="download-agreement" 
                               type="checkbox" 
                               value="@T("DownloadableProducts.IAgree")"
                               aria-controls="continue-downloading" />
                        @T("DownloadableProducts.IAgree")
                    </label>
                </div>
                <button id="continue-downloading" 
                        type="submit"
                        class="btn"
                        value="@T("Common.Continue")"
                        aria-disabled="true"
                        disabled
                        onclick="setLocation('@Url.Action("GetDownload", "Download", new { id = Model.OrderItemGuid, agree = true, fileVersion = Model.FileVersion })')">
                    <i class="fa fa-check" aria-hidden="true"></i>
                    <span>@T("Common.Continue")</span>
                </button>
            </div>
        </fieldset>
    </div>
</div>

<script sm-target-zone="scripts" data-origin="user-agreement">
    $(function () {
        $(document).on('change', '#download-agreement', function () {
            if ($('#download-agreement').is(':checked')) {
                $('#continue-downloading')
                    .prop('disabled', false)
                    .attr('aria-disabled', 'false')
                    .removeClass('disabled')
                    .addClass("btn-info");
            } 
            else {
                $('#continue-downloading')
                    .addClass('disabled')
                    .attr('aria-disabled', 'true')
                    .prop('disabled', true)
                    .removeClass("btn-info");
            }
        });
    });
</script>